Skip to content

Conversation

robertky
Copy link
Member

Summary

Closes #21.

  • Adds src/hooks/useFavorites.ts: stores unique book keys in localStorage under t19.favorites, restores them on load, and safely falls back to an empty list for invalid data
  • Adds src/components/FavoriteButton.tsx: an accessible favorite toggle on the displayed book card, including aria-pressed and the book title in its accessible name
  • Adds src/components/FavoritesView.tsx: a favorites section with each book’s title, author, and a separate remove control
  • Updates src/components/BookCard.tsx and src/App.tsx to connect the toggle, saved keys, and favorites overview

User flow

  1. Add the currently displayed book to favorites.
  2. The book appears in the Favorites section.
  3. Refresh or reopen the browser: the favorite remains saved.
  4. Remove the book from the Favorites section or toggle it off from the book card.

Tests

  • useFavorites tests storage updates, restoring saved keys, and corrupt localStorage data
  • FavoriteButton tests accessible state and clicking the toggle
  • FavoritesView tests title, author, and removal behavior
  • App test covers adding, reloading, restoring, and removing a favorite
  • Snapshots added deliberately for the new components and updated deliberately for App
  • Tests use MSW only; no real network calls

Validation

  • npm run format:check
  • npm run lint
  • npm test — 38 passed
  • npm run build

@robertky robertky requested a review from a team as a code owner September 10, 2026 09:51
@robertky robertky added status: in-review PR is open and awaiting review ai-assisted Substantial AI-generated code (documented per spec) labels Sep 10, 2026
Copy link
Member

@rachelks rachelks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. The favorites implementation and accessibility look good, but this branch seems to be behind the latest main and App.tsx is missing the navigation/jump-list changes from PR #26. Could you bring the branch up to date with main and verify that both features still work together before merging?

@robertky
Copy link
Member Author

Rebased onto the latest main after #26. Favorites now work with the navigation flow, and CI is green again. Ready for review.

Copy link
Member

@rachelks rachelks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now! I tested adding, restoring, and removing favorites, including keyboard navigation. The localStorage persistence and accessibility look good, and all validation checks pass. Approved.

@rachelks rachelks merged commit 9eba455 into main Sep 10, 2026
1 check passed
Sign in to join this conversation on GitHub.
Labels
ai-assisted Substantial AI-generated code (documented per spec) status: in-review PR is open and awaiting review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: Favorites toggle, overview, and localStorage persistence
2 participants